Problem/Motivation

Sometimes when AddToAny share buttons field is used in Views, the render method fails with the following message

Uncaught PHP Exception Error: "Call to a member function access() on null" at web/modules/contrib/addtoany/src/Plugin/views/field/NodeAddToAnyShare.php line 29

It's happened when values to render aren't entity node objects.

Proposed resolution

Add a validation before rendering in the same if of check access in src/Plugin/views/field/NodeAddToAnyShare.php line 29

if ($entity->access('view')) {

New Validation:

if ($entity instanceof \Drupal\Core\Entity\EntityInterface && $entity->access('view')) {

Remaining tasks

  • Create fork
  • Add validation in code
  • Propose merge request

Issue fork addtoany-3519190

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

aldibier created an issue. See original summary.

aldibier’s picture

Issue summary: View changes

aldibier’s picture

Status: Active » Needs review

Please review the code changes